<!doctype html>
<html>


<head>
  <meta charset="utf-8">
  <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>Hello APP</title>
  <link rel="stylesheet" type="text/css" href="./css/api.css"/>
  <style type="text/css">
    html,
    body {
      height: 100%;
      background-color: #fff;
    }

    .wrap {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-flex-flow: column;
    }

    header {
      height: 44px;
      width: 100%;
      text-align: center;
      background-color: #81a9c3;
      color: #fff;
      line-height: 44px;
      font-size: 20px;
    }

    .flex-1 {
      -webkit-box-flex: 1;
      -webkit-flex: 1;
    }

    footer {
      height: 30px;
      width: 100%;
      background-color: #81a9c3;
      color: white;
      line-height: 30px;
      text-align: center;
    }
  </style>
</head>

<body class="wrap">
<header></header>
<section class="flex-1">

</section>

<footer></footer>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
  apiready = function () {
    $api.setStorage("backapi", "http://192.168.1.89/");
    api.requestPermission({
      list: ['storage', 'camera'],
      code: 1
    }, function (ret, err) {
      // api.alert({
      //     msg:JSON.stringify(ret)
      // });
    });

    var intro_ist = $api.getStorage("introist");
    if (!intro_ist) {
      api.openWin({
        name: 'index_intro',
        url: 'html/yindaoye/intro_index.html',
        pageParam: {
          name: 'test1'
        }
      });
    } else {
      api.openFrame({
        name: 'index_c',
        url: 'html/index.html',
        pageParam: {
          name: 'test'
        }
      });
    }
    $api.setStorage('jiluji', '1');
    api.addEventListener({
      name: 'zsygsj'
    }, function (ret, err) {
      if (ret.value.id == 1) {

        NVTabBar.setSelect({
          index: ret.value.id,
          selected: "#FC8622",
          icons: ["widget://image/jishou1.png"]
        });
      } else if (ret.value.id == 3) {

        NVTabBar.setSelect({
          index: ret.value.id,
          selected: "#FC8622",
          icons: ["widget://image/xiangmu1.png"]
        });
      }
    });

    api.addEventListener({
      name: 'hsy'
    }, function (ret, err) {
      if (ret.value.id == 0) {
        api.setFrameGroupIndex({
          name: 'group1',
          index: 0
        });
        NVTabBar.setSelect({
          index: ret.value.id,
          selected: "#FC8622",
          icons: ["widget://image/index1.png"]
        });
      }
    });

    api.openFrameGroup({
      name: 'group1',
      background: '#000',
      scrollEnabled: false,
      rect: {
        x: 0,
        y: 0,
        w: 'auto',
        h: api.winHeight - 50
      },
      index: 0,
      preload: 0,
      frames: [{
        name: 'index',
        url: 'html/index.html',
        bgColor: '#fff',

      }, {
        name: 'list_jishou',
        url: 'html/jishou/list_jishou.html',
        bgColor: '#fff'
      }, {
        name: 'publicitem',
        url: '',
        bgColor: '#fff'
      }, {
        name: 'list_xmxq',
        url: 'html/xmxq/list_xmxq.html',
        bgColor: '#fff'
      }, {
        name: 'person',
        url: 'html/person/person.html',
        bgColor: '#fff'
      }]
    }, function (ret, err) {
      if (ret) {
        console.log(JSON.stringify(ret));
      } else {
        console.log(JSON.stringify(err));
      }
    });

    //$api.rmStorage('member');
    NVTabBar = api.require('NVTabBar');
    NVTabBar.open({
      styles: {
        bg: '#FFF',
        //bg:"widget://image/NVTabBar/tabbar_bg.png",
        h: 50,
        dividingLine: {
          width: 0.5,
          color: '#FFF'
        },
        badge: {
          bgColor: '#FFF',
          numColor: '#FFF',
          size: 6.0,
          centerX: 40,
          centerY: 6
        }
      },
      items: [{
        w: api.winWidth / 5.0,
        bg: {
          marginB: 0,
          image: '#FFF'
        },
        iconRect: {
          w: 21.0,
          h: 21.0,
        },
        icon: {
          normal: 'widget://image/index.png',
          highlight: 'widget://image/index1.png',
          selected: 'widget://image/index1.png'
        },
        title: {
          text: '首页',
          size: 14.0,
          normal: '#696969',
          selected: '#FC8622',
          marginB: 6.0
        }
      }, {
        w: api.winWidth / 5.0,
        bg: {
          marginB: 0,
          image: '#FFF'
        },
        iconRect: {
          w: 21.0,
          h: 21.0,
        },
        icon: {
          normal: "widget://image/jishou.png",
          highlight: "widget://image/jishou1.png",
          selected: "widget://image/jishou1.png",
        },
        title: {
          text: '机手列表',
          size: 14.0,
          normal: '#696969',
          selected: '#FC8622',
          marginB: 6.0
        }
      }, {

        w: api.winWidth / 5.0,
        bg: {
          marginB: 10,
          image: 'rgba(255,255,255,0)'
        },
        iconRect: {
          w: 40.0,
          h: 40.0,
        },
        icon: {
          normal: "widget://image/nav_tab_2_on.png",
          highlight: "widget://image/nav_tab_2_on.png",
          selected: "widget://image/nav_tab_2_on.png",
        },
        title: {
          text: '发布',
          size: 14.0,
          normal: '#696969',
          selected: '#FC8622',
          marginB: 6.0
        }
      }, {
        w: api.winWidth / 5.0,
        bg: {
          marginB: 0,
          image: '#FFF'
        },
        iconRect: {
          w: 21.0,
          h: 21.0,
        },
        icon: {
          normal: "widget://image/xiangmu.png",
          highlight: "widget://image/xiangmu1.png",
          selected: "widget://image/xiangmu1.png",
        },
        title: {
          text: '项目需求',
          size: 14.0,
          normal: '#696969',
          selected: '#FC8622',
          marginB: 6.0
        }
      }, {
        w: api.winWidth / 5.0,
        bg: {
          marginB: 0,
          image: '#FFF'
        },
        iconRect: {
          w: 21.0,
          h: 21.0,
        },
        icon: {
          normal: 'widget://image/wode.png',
          highlight: " widget://image/wode1.png",
          selected: "widget://image/wode1.png"
        },
        title: {
          text: '我的',
          size: 14.0,
          normal: '#696969',
          selected: '#FC8622',
          marginB: 6.0
        }
      }],
      selectedIndex: 0
    }, function (ret, err) {
      if (ret.eventType == "click" && ret.index == 0) {
        api.setFrameGroupIndex({
          name: 'group1',
          index: 0
        });
        api.closeFrame({
          name: 'index_public'
        });
        $api.setStorage('jiluji', '1');
      }
      if (ret.eventType == "click" && ret.index == 1) {
        if ($api.getStorage("shenfen") == 3) {
          api.toast({
            msg: '商家账号无法访问',
            duration: 2000,
            location: 'bottom'
          });

        } else {
          api.setFrameGroupIndex({
            name: 'group1',
            index: 1
          });
        }
        api.closeFrame({
          name: 'index_public'
        });
        $api.setStorage('jiluji', '1');
      }

      if (ret.eventType == "click" && ret.index == 2) {

        if ($api.getStorage('jiluji') == 1) {
          api.openFrame({
            name: 'index_public',
            url: 'widget://html/index_public.html',
            rect: {
              x: api.winWidth / 2 - 70,
              y: api.winHeight - 150,
              w: 140,
              h: 60
            },

            bounces: true,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true,
            animation: {
              type: "none",                //动画类型（详见动画类型常量）
              subType: "from_right",       //动画子类型（详见动画子类型常量）
              duration: 300
            }
          });
          $api.setStorage('jiluji', '0');
        } else if ($api.getStorage('jiluji') == 0) {
          api.closeFrame({
            name: 'index_public'
          });
          $api.setStorage('jiluji', '1');

        }

      }

      if (ret.eventType == "click" && ret.index == 3) {
        if ($api.getStorage("shenfen") == 3) {
          api.toast({
            msg: '商家账号无法访问',
            duration: 2000,
            location: 'bottom'
          });

        } else {
          api.setFrameGroupIndex({
            name: 'group1',
            index: 3
          });
        }
        api.closeFrame({
          name: 'index_public'
        });
        $api.setStorage('jiluji', '1');
      }
      if (ret.eventType == "click" && ret.index == 4) {
        var member = $api.getStorage("member");
        console.log(member)
        if (member == null) {

          api.openWin({
            name: 'login',
            url: 'widget://html/person/login_win.html',
            slidBackEnabled: false,

            pageParam: {
              name: 'test'
            }
          });
        } else {
          api.setFrameGroupIndex({
            name: 'group1',
            index: 4
          });
        }
        api.closeFrame({
          name: 'index_public'
        });
        $api.setStorage('jiluji', '1');
      }
    });

  }
  var NVTabBar;


</script>

</html>
